
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
<title>Bootstrap 101 Template</title>

<!-- Bootstrap -->
<link
	href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css"
	rel="stylesheet">

<!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
<!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
<!--[if lt IE 9]>
      <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
<link rel="stylesheet" href="<%=basePath%>statics/css/zIndex.css"
	type="text/css"></link>
<link rel="stylesheet" href="<%=basePath%>statics/css/public.css"
	type="text/css"></link>

</head>
<body>
	<c:import url="head.jsp"></c:import>

	<div class="container">
		<div class="row">
			<div class="col-xs-1 col-sm-3 col-md-4"></div>
			<form class="form-signin  col-xs-10 col-sm-6 col-md-4"
				action="javascript:login();">
				<h2 class="form-signin-heading">登录</h2>
				<div class="input-group">
					<span class="input-group-addon glyphicon glyphicon-user"></span><input
						type="account" id="inputAccount" name="inputAccount"
						class="form-control" placeholder="账号" required autofocus>
				</div>
				<!-- /input-group -->
				<div class="input-group">
					<span class="input-group-addon glyphicon glyphicon-lock"></span><input
						type="password" id="inputPassword" name="inputPassword"
						class="form-control" placeholder="密码" required autofocus>
				</div>
				<!-- /input-group -->
				<div class="checkbox">
					<label> <input type="checkbox" value="remember-me">记住密码</label>
				</div>
				<button class="btn btn-lg btn-primary btn-block" type="submit">登陆</button>
			</form>
			<div class="col-xs-1 col-sm-3 col-md-4"></div>
		</div>
	</div>
	<!-- /container -->




	<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
	<script
		src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
	<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
	<script
		src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>

	<input type="hidden" id="basePath" value="<%=basePath%>">
	<script type="text/javascript">
		var basePath = $("#basePath").val();
		//登陆
		function login() {
			var inputAccount = $("#inputAccount").val();
			var inputPassword = $("#inputPassword").val();
			$
					.ajax({
						url : basePath + "login.do",
						type : "POST",
						data : {
							"inputAccount" : inputAccount,
							"inputPassword" : inputPassword
						},
						dataType : "json",
						async : false,
						success : function(jsonMessage) {
							//window.location.href = basePath + "listfile.do";

							if (jsonMessage == "user登陆成功！") {
								window.location.href = basePath + "toIndex";
							} else if (jsonMessage == "referee登陆成功！") {
								window.location.href = basePath
										+ "toReferee.do";
							} else if (jsonMessage == "admin登陆成功！") {
								window.location.href = basePath + "toAdmin";
							} else {
								/*$(".container")
								 .prepend(
								 "<div class='alert alert-danger zone' role='alert'>...</div>");*/
								$("#head")
										.append(
												"<div name='message' class='alert alert-danger alert-dismissible zone fade in right' role='alert'>"
														+ jsonMessage
														+ "<button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>&times;</span></button>"
														+ "</div>");
								setTimeout(function() {
									$("[name=message]").alert('close');
								}, 3000);
							}
						},
						error : function() {
							alert("登陆异常！");
						}
					});
		}
	</script>
</body>
</html>